﻿using System.Linq;
using Sidvall.Collections;

namespace Sidvall.WorkItemManager.UI.Entities
{
    public sealed partial class WorkConditionCollection : Sidvall.WorkItemManager.UI.Entities.Core.BusinessBaseCollection<WorkCondition>
    {
        #region Public Members
        
        #region LoadWorkItemWorkConditionsAsync

        public async System.Threading.Tasks.Task LoadWorkItemWorkConditionsAsync()
        {
            await LoadWorkItemWorkConditionsAsync(false, false, null, null, null);
        }
        public async System.Threading.Tasks.Task LoadWorkItemWorkConditionsAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchListCriteria<global::Sidvall.WorkItemManager.Data.Fields.WorkItemWorkConditionField, global::Sidvall.WorkItemManager.Data.Relations.WorkItemWorkConditionRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkConditionManager.LoadWorkItemWorkConditionsAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);
        }

        #endregion
        #region AcceptChanges

        public void AcceptChanges()
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkConditionManager.AcceptChanges(this);
        }

        #endregion
        #region Clone

        public WorkConditionCollection Clone()
        {
            var copySettings = Sidvall.Data.CopySettings.Clone();
            return Copy(copySettings);
        }

        #endregion
        #region Copy

        public WorkConditionCollection Copy()
        {
            return Copy(null);
        }
        public WorkConditionCollection Copy(Sidvall.Data.CopySettings copySettings)
        {
            var items = new WorkConditionCollection();
            Import(items, this, copySettings);
            return items;
        }

        #endregion
        #region Import

        public void Import(System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkCondition> items)
        {
            Import(items, null);
        }
        partial void OnAfterImport(System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkCondition> source, Sidvall.Data.CopySettings copySettings);
        public void Import(System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkCondition> items, Sidvall.Data.CopySettings copySettings)
        {
            Import(this, items, copySettings);
        }
        partial void OnAfterImport(WorkConditionCollection destination, System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkCondition> source, Sidvall.Data.CopySettings copySettings);
        private void Import(WorkConditionCollection destination, System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkCondition> source, Sidvall.Data.CopySettings copySettings)
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkConditionManager.Import(destination, source, copySettings);
            OnAfterImport(destination, source, copySettings);
        }
        partial void OnAfterImport(WorkConditionCollection destination, WorkConditionCollection source, Sidvall.Data.CopySettings copySettings);
        private void Import(WorkConditionCollection destination, WorkConditionCollection source, Sidvall.Data.CopySettings copySettings)
        {
            Import(destination, source as System.Collections.Generic.IEnumerable<global::Sidvall.WorkItemManager.Data.IWorkCondition>, copySettings);
            OnAfterImport(destination, source, copySettings);
        }

        #endregion
        #region SaveItemsAsync

        public async System.Threading.Tasks.Task<WorkConditionCollection> SaveItemsAsync()
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkConditionManager.SaveItemsAsync(this);
        }
        public async System.Threading.Tasks.Task<WorkConditionCollection> SaveItemsAsync(Sidvall.Data.SaveMode mode)
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkConditionManager.SaveItemsAsync(this, mode);
        }
        public async System.Threading.Tasks.Task<WorkConditionCollection> SaveItemsAsync(Sidvall.Data.SaveSettings settings)
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.DataPortal.WorkConditionManager.SaveItemsAsync(this, settings);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkConditionManager.ValidateAsync(this);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            return await global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkConditionManager.ValidateAsync(this, settings);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkConditionManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.WorkItemManager.UI.SystemContext.Current.EntityFacade.WorkConditionManager.Initialize(this, settings);
        }

        #endregion

        #endregion
        #region Constructors

        public WorkConditionCollection()
        {
        }

        #endregion
    }
}